home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: jeremyx@ix.netcom.com(Jeremy Johnston )
- Newsgroups: comp.lang.c++
- Subject: Re: U MUST READ THIS!!!!!
- Date: 11 Feb 1996 18:47:48 GMT
- Organization: Netcom
- Message-ID: <4fldkk$k3h@ixnews5.ix.netcom.com>
- References: <4epbn1$4hq@ixnews7.ix.netcom.com> <4fl0l2$pl1@news1.delphi.com>
- NNTP-Posting-Host: hun-al1-03.ix.netcom.com
- X-NETCOM-Date: Sun Feb 11 10:47:48 AM PST 1996
-
- In <4fl0l2$pl1@news1.delphi.com> JGUILLORY@delphi.com writes:
- >
- >
- >Quoting jeremyx from a message in comp.lang.c++
- > je> Everyone keeps telling me not to use the "goto"
- > je> statement,they act like it's the plague! What is wrong with the
- goto
- > je> statement & what can i use in it's place?
- >
- >Proper structured code needs no GOTO's eg: Consider the following:
- >(untested)
- >
- >#include <stdio.h>
- >
- >void main(void) {
- >FILE *f;
- >label E1;
- >char command[]="DIR/W";
- >
- > f = fopen("TEST.BAT","wt");
- > if (f==NULL) goto E1;
- > fprintf(f,"%s\n",command);
- > fclose(f);
- >E1:
- >}
- >
- >-- My syntax on the goto / Labels may be off, as I haven't used goto's
- > in C/C++ much.... (never needed them....)
- >
- >The above could be simply re-written as:
- >
- >#include <stdio.h>
- >
- >void main(void) {
- >FILE *f;
- >char command[]="DIR/W";
- >
- > f = fopen("TEST.BAT","wt");
- > if (f!=NULL) {
- > fprintf(f,"%s\n",command);
- > fclose(f);
- > }
- >}
- >
- >Without GOTO's, you have 1 Start, and 1 Stop, and can write a
- flow-chart
- >to match it very easily, with GOTO's you have 1 start, many stop's,
- >and a big headache to look at it....
- >
- >John H. Guillory
- >JGuillory@Delphi.Com
- >
- >Rainbow V 1.17.0 for Delphi - Test Drive
- >
-
- WHOA!!!!!!!!! THat looked like alien writing! what did that program
- do?! i know it open a file but what was all that other stuff?! This is
- the most complicated language i know ( i thought latin was hard! )
- BASIC is much easier>
-